package com.boot.main.controller;

import com.boot.main.entity.BcomCategory;
import com.boot.main.entity.BcomSiteCategory;
import com.boot.main.service.IBlogCategoryService;
import com.boot.main.service.IBlogSiteCategoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/v1/api")
@Api(tags = "博客分类管理")
public class BlogSiteCategoryController {
    @Resource
    private IBlogSiteCategoryService blogSiteCategoryService;

    @RequestMapping(value="/blog/site/categorys", method = RequestMethod.GET)
    @ApiOperation(value="获取分类列表")
    public Object getSiteCategorys(@RequestParam("status") Integer status){
        return blogSiteCategoryService.getSiteCategorys(status);
    }

    @RequestMapping(value="/blog/site/category", method = RequestMethod.POST)
    @ApiOperation(value="新增分类")
    public Object saveSiteCategory(@RequestBody BcomSiteCategory category){
        return blogSiteCategoryService.saveSiteCategory(category);
    }

    @RequestMapping(value="/blog/site/category/{id}", method = RequestMethod.PUT)
    @ApiOperation(value="修改分类")
    public Object updateSiteCategory(@RequestBody BcomSiteCategory category){
        return blogSiteCategoryService.updateSiteCategory(category);
    }

    @RequestMapping(value="/blog/site/category/{id}", method = RequestMethod.DELETE)
    @ApiOperation(value="删除分类")
    public Object deleteSiteCategory(@PathVariable Long id){
        return blogSiteCategoryService.deleteSiteCategory(id);
    }
}
